<?php

/*
=====================================================
 FluxBB - Delux Board Converstations (DBC)
-----------------------------------------------------
 http://dbc-forum.com/
 http://fluxbb.org/
-----------------------------------------------------
 Copyright (c) 2010,2011 FluxBB - Delux Board Conversations (DBC)
-----------------------------------------------------
 Предсловие: Данный скрипт (DBC) не является работой с нуля, то 
 есть ядром скрипта всё также остаётся FuxBB,но теперь в оболочке
 DBC.
=====================================================
*/

define('WITT_ENABLE', 300);
define('DBC_ROOT', './');
define('DBC_VIEWTOPIC', 1);
require DBC_ROOT.'engine/common.php';

if ($DBC_user['g_read_board'] == '0')
	message($lang_common['No view']);

$action = isset($_GET['action']) ? $_GET['action'] : null;
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$pid = isset($_GET['pid']) ? intval($_GET['pid']) : 0;
$sword = (isset($_GET['words'])) ? strtolower(trim($_GET['words'])) : null;

if ($id < 1 && $pid < 1)
	message($lang_common['Bad request']);

// Load the viewtopic.php language file
require DBC_ROOT.'language/'.$DBC_user['language'].'/topic.php';
require DBC_ROOT.'language/'.$DBC_user['language'].'/reputation.php';

// If a post ID is specified we determine topic ID and page number so we can redirect to the correct message
if ($pid)
{
	$result = $db->query('SELECT topic_id FROM '.$db->prefix.'posts WHERE id='.$pid) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
	if (!$db->num_rows($result))
		message($lang_common['Bad request']);

	$id = $db->result($result);

	// Determine on what page the post is located (depending on $forum_user['disp_posts'])
	$result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'posts WHERE topic_id='.$id.' AND id<'.$pid) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
	$num_posts = $db->result($result) + 1;

	$_GET['p'] = ceil($num_posts / $DBC_user['disp_posts']);
}

// If action=new, we redirect to the first new post (if any)
else if ($action == 'new')
{
	if (!$DBC_user['is_guest'])
	{
		// We need to check if this topic has been viewed recently by the user
		$tracked_topics = get_tracked_topics();
		$last_viewed = isset($tracked_topics['topics'][$id]) ? $tracked_topics['topics'][$id] : $DBC_user['last_visit'];

		$result = $db->query('SELECT MIN(id) FROM '.$db->prefix.'posts WHERE topic_id='.$id.' AND posted>'.$last_viewed) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
		$first_new_post_id = $db->result($result);

		if ($first_new_post_id)
		{
			header('Location: topic_'.$first_new_post_id.'#p'.$first_new_post_id);
			exit;
		}
	}

	// If there is no new post, we go to the last post
	header('Location: topic_'.$id.'&action=last');
	exit;
}

// If action=last, we redirect to the last post
else if ($action == 'last')
{
	$result = $db->query('SELECT MAX(id) FROM '.$db->prefix.'posts WHERE topic_id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
	$last_post_id = $db->result($result);

	if ($last_post_id)
	{
		header('Location: topic_'.$post_id.'#p'.$last_post_id);
		exit;
	}
}

// Online Topic

if (defined('WITT_ENABLE'))
{
	$now = time();
	$remote_addr = get_remote_address();
	if (empty($DBC_user['witt_data']))
	{
		$witt_ar = array();
		$witt_ar[$id] = $now;
		$DBC_user['witt_data'] = serialize($witt_ar);
	}
	else
	{
		$witt_ar = unserialize($DBC_user['witt_data']);
		$witt_ar[$id] = $now;
		arsort($witt_ar);
		$witt_du = array();
		$i = 0;
		foreach ($witt_ar as $key => $value)
		{
			if ($i > 8 || $value < $now - WITT_ENABLE) break;
			$witt_du[$key] = $value;
			$i++;
		}
		$DBC_user['witt_data'] = serialize($witt_du);
	}

	if ($DBC_user['is_guest'])
	{
		// Update online list
		if (!$DBC_user['logged'])
		{
			$DBC_user['logged'] = time();

			// With MySQL/MySQLi/SQLite, REPLACE INTO avoids a user having two rows in the online table
			switch ($db_type)
			{
				case 'mysql':
				case 'mysqli':
				case 'mysql_innodb':
				case 'mysqli_innodb':
				case 'sqlite':
					$db->query('REPLACE INTO '.$db->prefix.'online (user_id, ident, logged, witt_data) VALUES(1, \''.$db->escape($remote_addr).'\', '.$DBC_user['logged'].', \''.$db->escape($DBC_user['witt_data']).'\')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
					break;

				default:
					$db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged, witt_data) SELECT 1, \''.$db->escape($remote_addr).'\', '.$DBC_user['logged'].', \''.$db->escape($DBC_user['witt_data']).'\' WHERE NOT EXISTS (SELECT 1 FROM '.$db->prefix.'online WHERE ident=\''.$db->escape($remote_addr).'\')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
					break;
			}
		}
		else
			$db->query('UPDATE '.$db->prefix.'online SET logged='.$now.', witt_data=\''.$db->escape($DBC_user['witt_data']).'\' WHERE ident=\''.$db->escape($remote_addr).'\'') or error('Unable to update online list', __FILE__, __LINE__, $db->error());
	}
	else
	{
		// Define this if you want this visit to affect the online list and the users last visit data
		if (!defined('DBC_QUIET_VISIT'))
		{
			// Update the online list
			if (!$DBC_user['logged'])
			{
				$DBC_user['logged'] = $now;

				// With MySQL/MySQLi/SQLite, REPLACE INTO avoids a user having two rows in the online table
				switch ($db_type)
				{
					case 'mysql':
					case 'mysqli':
					case 'mysql_innodb':
					case 'mysqli_innodb':
					case 'sqlite':
						$db->query('REPLACE INTO '.$db->prefix.'online (user_id, ident, logged, witt_data) VALUES('.$DBC_user['id'].', \''.$db->escape($DBC_user['username']).'\', '.$DBC_user['logged'].', \''.$db->escape($DBC_user['witt_data']).'\')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
						break;

					default:
						$db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged, witt_data) SELECT '.$DBC_user['id'].', \''.$db->escape($DBC_user['username']).'\', '.$DBC_user['logged'].', \''.$db->escape($DBC_user['witt_data']).'\' WHERE NOT EXISTS (SELECT 1 FROM '.$db->prefix.'online WHERE user_id='.$DBC_user['id'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error());
						break;
				}

				// Reset tracked topics
				set_tracked_topics(null);
			}
			else
			{
				// Special case: We've timed out, but no other user has browsed the forums since we timed out
				if ($DBC_user['logged'] < ($now-$DBC_config['o_timeout_visit']))
				{
					$db->query('UPDATE '.$db->prefix.'users SET last_visit='.$DBC_user['logged'].' WHERE id='.$DBC_user['id']) or error('Unable to update user visit data', __FILE__, __LINE__, $db->error());
					$DBC_user['last_visit'] = $DBC_user['logged'];
				}

				$idle_sql = ($DBC_user['idle'] == '1') ? ', idle=0' : '';
				$db->query('UPDATE '.$db->prefix.'online SET logged='.$now.$idle_sql.', witt_data=\''.$db->escape($DBC_user['witt_data']).'\' WHERE user_id='.$DBC_user['id']) or error('Unable to update online list', __FILE__, __LINE__, $db->error());

				// Update tracked topics with the current expire time
				if (isset($_COOKIE[$cookie_name.'_track']))
					forum_setcookie($cookie_name.'_track', $_COOKIE[$cookie_name.'_track'], $now + $DBC_config['o_timeout_visit']);
			}
		}
		else
		{
			if (!$DBC_user['logged'])
				$DBC_user['logged'] = $DBC_user['last_visit'];
		}
	}

	$witt_us = array(1 => array());
	update_users_online($id, $witt_us);
	
}


// Online Topic


// Fetch some info about the topic
if (!$DBC_user['is_guest'])
	$result = $db->query('SELECT t.stick_fp, t.subject, t.topic_desc, t.closed, t.num_replies, t.sticky, t.first_post_id, t.last_post_id, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$DBC_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$DBC_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
else
	$result = $db->query('SELECT t.stick_fp, t.subject, t.topic_desc, t.closed, t.num_replies, t.sticky, t.first_post_id, t.last_post_id, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$DBC_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());

if (!$db->num_rows($result))
	message($lang_common['Bad request']);

$cur_topic = $db->fetch_assoc($result);

// Sort out who the moderators are and if we are currently a moderator (or an admin)
$mods_array = ($cur_topic['moderators'] != '') ? unserialize($cur_topic['moderators']) : array();
$is_admmod = ($DBC_user['g_id'] == DBC_ADMIN || ($DBC_user['g_moderator'] == '1' && array_key_exists($DBC_user['username'], $mods_array))) ? true : false;
$link_topic = ''.($DBC_config['o_base_url']).'/topic_'.$id.'';


// Can we or can we not post replies?
if ($cur_topic['closed'] == '0')
{
	if (($cur_topic['post_replies'] == '' && $DBC_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1' || $is_admmod)
		$post_link = "\t\t\t".'<p class="postlink conr fbutton_add"><a href="post_tid'.$id.'"><img src="engine/skins/images/arrow_rotate_clockwise.png" align="absmiddle" class="page_add" alt="" /><a href="post_tid'.$id.'">'.$lang_topic['Post reply'].'</a></p>'."\n";
	else
		$post_link = '';
}
else
{
	$post_link = $lang_topic['Topic closed'];

	if ($is_admmod)
		$post_link .= ' / <a href="post_tid'.$id.'">'.$lang_topic['Post reply'].'</a>';

	$post_link = "\t\t\t".'<p class="postlink conr">'.$post_link.'</p>'."\n";
}


// Add/update this topic in our list of tracked topics
if (!$DBC_user['is_guest'])
{
	$tracked_topics = get_tracked_topics();
	$tracked_topics['topics'][$id] = time();
	set_tracked_topics($tracked_topics);
}


// Determine the post offset (based on $_GET['p'])
$num_pages = ceil(($cur_topic['num_replies'] + 1) / $DBC_user['disp_posts']);

$p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']);
$start_from = $DBC_user['disp_posts'] * ($p - 1);

// Generate paging links
$paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'topic_'.$id);


if ($DBC_config['o_censoring'] == '1')
	$cur_topic['subject'] = censor_words($cur_topic['subject']);
	$cur_topic['topic_desc'] = censor_words($cur_topic['topic_desc']);

$quickpost = false;
if ($DBC_config['o_quickpost'] == '1' &&
	!$DBC_user['is_guest'] &&
	($cur_topic['post_replies'] == '1' || ($cur_topic['post_replies'] == '' && $DBC_user['g_post_replies'] == '1')) &&
	($cur_topic['closed'] == '0' || $is_admmod))
{
	$required_fields = array('req_message' => $lang_common['Message']);
	$quickpost = true;
}

if (!$DBC_user['is_guest'] && $DBC_config['o_subscriptions'] == '1')
{
	if ($cur_topic['is_subscribed'])
		// I apologize for the variable naming here. It's a mix of subscription and action I guess :-)
		$subscraction = "\t\t".'<span>'.$lang_topic['Is subscribed'].' - </span><a href="misc.php?unsubscribe='.$id.'">'.$lang_topic['Unsubscribe'].'</a>'."\n";
	else
		$subscraction = "\t\t".'<a href="misc.php?subscribe='.$id.'">'.$lang_topic['Subscribe'].'</a>'."\n";
}
else
	$subscraction = '';


if ($DBC_config['o_feed_type'] == '1')
	$page_head = array('feed' => '<link rel="alternate" type="application/rss+xml" href="extern.php?action=feed&amp;tid='.$id.'&amp;type=rss" title="'.$lang_common['RSS topic feed'].'" />');
else if ($DBC_config['o_feed_type'] == '2')
	$page_head = array('feed' => '<link rel="alternate" type="application/atom+xml" href="extern.php?action=feed&amp;tid='.$id.'&amp;type=atom" title="'.$lang_common['Atom topic feed'].'" />');

if ($quickpost)
{
	$apq  = 'var apq = {\'Must\' : \''.$lang_common['Must'].'\'';
	$apq .= ', \'Loading\' : \''.$lang_common['Loading'].'\'';
	$apq .= ', \'Flag\' : \'Topic\'';
	$apq .= '}';
	$page_head['apq'] = '<script type="text/javascript">'."\n".'/* <![CDATA[ */'."\n".$apq."\n".'/* ]]> */'."\n".'</script>';
	$page_head['bbcode'] = '<script type="text/javascript" src="engine/classes/js/post.js"></script>';
}

$page_title = array(DBC_htmlspecialchars($DBC_config['o_board_title']), DBC_htmlspecialchars($cur_topic['forum_name']), DBC_htmlspecialchars($cur_topic['subject']));
define('DBC_ALLOW_INDEX', 1);
define('DBC_ACTIVE_PAGE', 'index');
require DBC_ROOT.'engine/engine.php';
$show = '5'; // Change 5 by the number of topics you want the mod to display
require DBC_ROOT.'engine/last_topics.php';
?>

<div class="linkst">
	<div class="inbox crumbsplus">
		<div class="pagepost">
			<p class="pagelink conl"><span class="contacts"><?php echo $paging_links ?></span></p>
			<span class="contacts" style="margin-left: 7px;"><a href="index.php"><?php echo $lang_common['Index'] ?></a>
			<span>»&#160;</span><a href="forum_<?php echo $cur_topic['forum_id'] ?>"><?php echo DBC_htmlspecialchars($cur_topic['forum_name']) ?></a>
			<span>»&#160;</span><?php echo DBC_htmlspecialchars($cur_topic['subject']) ?></span>
			<?php echo $post_link ?>
		</div>
		<div class="clearer"></div>
	</div>
</div>

<table width="100%" height="38" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" width="28" class="bg_forum_title_left"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td align="left" class="bg_forum_title_center"><span class="cat_title"><strong><?php echo DBC_htmlspecialchars($cur_topic['subject']) ?></strong> <?php echo DBC_htmlspecialchars($cur_topic['topic_desc']) ?></span></td>
<td align="center" width="28" class="bg_forum_title_right"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
</tr></table>

<?php


require DBC_ROOT.'engine/parser.php';

$post_count = isset($_GET['pcount']) ? intval($_GET['pcount']) : 0; // Keep track of post numbers

// Retrieve a list of post IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data
$result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$id.(isset($_GET['lpid']) ? ' AND id > '.intval($_GET['lpid']) : '').' ORDER BY id LIMIT '.$start_from.','.$DBC_user['disp_posts']) or error('Unable to fetch post IDs', __FILE__, __LINE__, $db->error());

$post_ids = array();
for ($i = 0;$cur_post_id = $db->result($result, $i);$i++)
	$post_ids[] = $cur_post_id;
$stick_fp_flag = ($cur_topic['stick_fp'] != 0);
$stick_fp_start_from = 0;
if ($stick_fp_flag)
	$post_ids[] = $cur_topic['first_post_id'];

$result = $db->query('SELECT id, message, poster, posted FROM '.$db->prefix.'warnings WHERE id IN ('.implode(',', $post_ids).')', true) or error('Unable to fetch warnings', __FILE__, __LINE__, $db->error());
$warnings = array();
while ($warning = $db->fetch_assoc($result))
	$warnings[$warning['id']] = '<cite>'.format_time($warning['posted']).' '.DBC_htmlspecialchars($warning['poster']).' '.$lang_common['wrote'].'</cite>'.parse_message($warning['message'], false).'';

// Retrieve the posts (and their respective poster/online status)
// add "g.g_pm, u.messages_enable," - New PMS - "u.warning_all," - Warnings - p.user_agent, - user agent
$result = $db->query('SELECT u.warning_all, u.email, u.title, u.gender, u.url, u.location, u.signature, u.email_setting, u.num_posts, u.rep_plus AS count_rep_plus, u.rep_minus AS count_rep_minus, u.reputation_enable, u.icq, u.Skype, u.vkontakte, u.registered, u.admin_note, u.messages_enable, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, p.edit_post, p.user_agent, g.g_id, g.g_title, g.g_user_title, g.g_pm FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE p.id IN ('.implode(',', $post_ids).') ORDER BY p.id') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
while ($cur_post = $db->fetch_assoc($result))
{
	if ($stick_fp_flag)
	{
		if ($post_count == 0 && $start_from > 0)
		{
			$stick_fp_start_from = $start_from;
			$start_from = 0;
		}
		else if ($start_from == 0 && $stick_fp_start_from > 0)
		{
			$post_count = 0;
			$start_from = $stick_fp_start_from;

?>
<hr/>
<?php
		}
	}
	$post_count++;
	$user_avatar = '';
	$user_info = array();
	$user_postt = array();
	$user_contacts = array();
	$post_actions = array();
	$is_online = '';
	$signature = '';

	// If the poster is a registered user
	if ($cur_post['poster_id'] > 1)
	{
		if ($cur_post['gender'] == 1)
			$cur_post['gender'] = 'male';
		else if ($cur_post['gender'] == 2)
			$cur_post['gender'] = 'female';
		else
			$cur_post['gender'] = NULL;

		if ($DBC_user['g_view_users'] == '1')
			$username = '<a href="user_'.$cur_post['poster_id'].'">'.DBC_htmlspecialchars($cur_post['username']).'</a>';
		else
			$username = DBC_htmlspecialchars($cur_post['username']);

		if ($DBC_user['g_view_users'] == '1')
			$username_t = ''.DBC_htmlspecialchars($cur_post['username']).'';
		else
			$username_t = DBC_htmlspecialchars($cur_post['username']);

		if ($DBC_user['g_view_users'] == '1')
			$poster_id = ''.DBC_htmlspecialchars($cur_post['poster_id']).'';
		else
			$poster_id = DBC_htmlspecialchars($cur_post['poster_id']);

		$user_title = get_title($cur_post);


		if ($DBC_config['o_censoring'] == '1')
			$user_title = censor_words($user_title);

		// Format the online indicator
		$is_online = (isset($online_users[$cur_post['poster_id']])) ? '<font color="blue">'.$lang_topic['Online'].'</font>' : '<font color="red">'.$lang_topic['Offline'].'</font>';

		if ($DBC_config['o_avatars'] == '1' && $DBC_user['show_avatars'] != '0')
		{
			if (isset($user_avatar_cache[$cur_post['poster_id']]))
				$user_avatar = $user_avatar_cache[$cur_post['poster_id']];
			else
				$user_avatar = $user_avatar_cache[$cur_post['poster_id']] = generate_avatar_markup($cur_post['poster_id']);
		}

		// We only show location, register date, post count and the contact links if "Show user info" is enabled
		if ($DBC_config['o_show_user_info'] == '1')
		{
			if ($cur_post['location'] != '')
			{
				if ($DBC_config['o_censoring'] == '1')
					$cur_post['location'] = censor_words($cur_post['location']);

				$user_info[] = '<li><span class="ft_detals">'.$lang_topic['From'].' '.DBC_htmlspecialchars($cur_post['location']).'</span></li>';
			}

			$user_info[] = '<li><span class="ft_detals">'.$lang_topic['Registered'].' '.format_time($cur_post['registered'], true).'</span></li>';

			if ($cur_post['icq'])
			{
			$user_info[] = '<li><span class="ft_detals">'.$lang_topic['user_icq'].' '.DBC_htmlspecialchars($cur_post['icq']).'</span></li>';

			}

			if ($DBC_config['o_show_post_count'] == '1' || $DBC_user['is_admmod'])
				$user_postt[] = '<li><span class="ft_posts">'.$lang_topic['Posts'].'</span> <span class="fc_posts"><a href="posts_uid'.$cur_post['poster_id'].'">'.forum_number_format($cur_post['num_posts']).' <img src="engine/skins/images/search.png" title="'.$lang_topic['Search_posts'].''.$username_t.' " align="absmiddle" border="0" /></a></span></li>';



			$user_reg[] = ''.format_time($cur_post['registered'], true).'';
			$user_land[] = ''.DBC_htmlspecialchars($cur_post['location']).'';
			$user_posts[] = ''.forum_number_format($cur_post['num_posts']).'';
			$user_icq[] = ''.DBC_htmlspecialchars($cur_post['icq']).'';
			$user_skype[] = ''.DBC_htmlspecialchars($cur_post['Skype']).'';


			// Now let's deal with the contact links (Email and URL)
			if ((($cur_post['email_setting'] == '0' && !$DBC_user['is_guest']) || $DBC_user['is_admmod']) && $DBC_user['g_send_email'] == '1')
				$user_contacts[] = '<span class="email"><a href="mailto:'.$cur_post['email'].'">'.$lang_common['Email'].'</a></span>';
			else if ($cur_post['email_setting'] == '1' && !$DBC_user['is_guest'] && $DBC_user['g_send_email'] == '1')
				$user_contacts[] = '<span class="email"><a href="misc.php?email='.$cur_post['poster_id'].'">'.$lang_common['Email'].'</a></span>';

			if ($cur_post['url'] != '')
			{
				if ($DBC_config['o_censoring'] == '1')
						$cur_post['url'] = censor_words($cur_post['url']);

				$user_contacts[] = '<span class="website"><a href="'.DBC_htmlspecialchars($cur_post['url']).'">'.$lang_topic['Website'].'</a></span>';
			}
		}
		if (!$DBC_user['is_guest'] && $DBC_config['o_pms_enabled'] == '1' && $DBC_user['g_pm'] == 1 && $DBC_user['messages_enable'] == 1 && $cur_post['poster_id'] != $DBC_user['id'])
			if ($DBC_user['g_id'] == DBC_ADMIN || ($cur_post['g_pm'] == 1 && $cur_post['messages_enable'] == 1))
			{
				$user_contacts[] = '<span class="pmsnew"><a href="pm_uid'.$cur_post['poster_id'].'">'.$lang_common['PM'].'</a></span>';
			}
		if ($DBC_user['is_admmod'])
		{
			$user_info[] = '<li><span class="ft_detals">'.$lang_topic['Warnings'].' <a href="search.php?action=show_user_warn&user_id='.$cur_post['poster_id'].'">'.$cur_post['warning_all'].'&nbsp;</a></span></li>';
			if ($DBC_user['g_id'] == DBC_ADMIN)
			$user_info[] = '<li><span class="ft_detals">'.$lang_topic['IP address logged'].' <a href="moderate.php?get_host='.$cur_post['id'].'" title="'.$cur_post['poster_ip'].'">'.$lang_topic['View_ip'].'</a></span></li>';


			if ($cur_post['admin_note'] != '')
				$user_info[] = '<li><span class="ft_detals">'.$lang_topic['Note'].' <strong>'.DBC_htmlspecialchars($cur_post['admin_note']).'</strong></span></li>';
		}
		else if ($cur_post['poster_id'] == $DBC_user['id'])
		{
			$user_info[] = '<li><span class="ft_detals">'.$lang_topic['Warnings'].' <a href="search.php?action=show_user_warn">&nbsp;'.$cur_post['warning_all'].'&nbsp;</a></span></li>';
    }
	}
	// If the poster is a guest (or a user that has been deleted)
	else
	{
		$username = DBC_htmlspecialchars($cur_post['username']);

		$cur_post['gender'] = NULL;

		if ($DBC_user['g_id'] == DBC_ADMIN)
			$user_info[] = '<dd><span><a href="moderate.php?get_host='.$cur_post['id'].'" title="'.$cur_post['poster_ip'].'">'.$lang_topic['IP address logged'].'</a></span></dd>';

		if ($DBC_config['o_show_user_info'] == '1' && $cur_post['poster_email'] != '' && !$DBC_user['is_guest'] && $DBC_user['g_send_email'] == '1')
			$user_contacts[] = '<span class="email"><a href="mailto:'.$cur_post['poster_email'].'">'.$lang_common['Email'].'</a></span>';
	}
		$user_title = colorize_group($cur_post['g_title'], $cur_post['g_id']);

		$user_rank = DBC_htmlspecialchars($cur_post['g_user_title']);

	// Generation post action array (quote, edit, delete etc.)
	if (!$is_admmod)
	{
		if (!$DBC_user['is_guest'])
			$post_actions[] = '<li class="postreport"><span><a href="misc.php?report='.$cur_post['id'].'"><img src="engine/skins/images/report.png" align="absmiddle" alt=""/> '.$lang_topic['Report'].'</a></span></li>';

		if ($cur_topic['closed'] == '0')
		{
//			if ($cur_post['poster_id'] == $DBC_user['id'])
			if ($cur_post['poster_id'] == $DBC_user['id'] && ($DBC_user['g_deledit_interval'] == 0 || $cur_post['edit_post'] == 1 || time()-$cur_post['posted'] < $DBC_user['g_deledit_interval']))
			{
				if ((($start_from + $post_count) == 1 && $DBC_user['g_delete_topics'] == '1') || (($start_from + $post_count) > 1 && $DBC_user['g_delete_posts'] == '1'))
					$post_actions[] = '<li class="postdelete"><span><a href="delete_'.$cur_post['id'].'"><img src="engine/skins/images/comment_delete.png" align="absmiddle" alt=""/> '.$lang_topic['Delete'].'</a></span></li>';
				if ($DBC_user['g_edit_posts'] == '1')
					$post_actions[] = '<li class="postedit"><span id="menu'.$cur_post['id'].'"><a onmouseover="ape_menu_hovered = true;" onmouseout="ape_menu_hovered = false;" onclick="if (ape_show_menu('.$cur_post['id'].')) {return true;} else {return false;}" href="edit_'.$cur_post['id'].'"><img src="engine/skins/images/comment_edit.png" align="absmiddle" alt=""/> '.$lang_topic['Edit'].'</a></span></li>';
			}

			if (($cur_topic['post_replies'] == '' && $DBC_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1')
			{
				$post_actions[] = '<li class="postquote"><span><a href="post_tid'.$id.'"><img src="engine/skins/images/comment_add.png" align="absmiddle" alt=""/> '.$lang_topic['Reply'].'</a></span></li>';
				if ($quickpost)
					$post_actions[] = '<li class="postquote"><span id="pq'.$cur_post['id'].'"><a href="post_tid'.$id.'&amp;qid='.$cur_post['id'].'" onmousedown="get_quote_text()" onclick="Quote(\''.DBC_htmlspecialchars($cur_post['username']).'\','.$cur_post['id'].'); return false;"><img src="engine/skins/images/comment_add.png" align="absmiddle" alt=""/> '.$lang_topic['Quote'].'</a></span></li>';
//					$post_actions[] = '<li class="postquote"><span><a onmousedown="get_quote_text()" href="javascript:Quote(\''.DBC_htmlspecialchars($cur_post['username']).'\')"><img src="engine/skins/images/comment_add.png" align="absmiddle" alt=""/> '.$lang_topic['QQuote'].'</a></span></li>';
			}
		}
	}
	else
	{
		if ($DBC_user['g_id'] != DBC_ADMIN)
			$post_actions[] = '<li class="postreport"><span><a href="misc.php?report='.$cur_post['id'].'">'.$lang_topic['Report'].'</a></span></li>';
		$post_actions[] = '<li class="postdelete"><span><a href="delete_'.$cur_post['id'].'"><img src="engine/skins/images/comment_delete.png" align="absmiddle" alt=""/> '.$lang_topic['Delete'].'</a></span></li>';
					$post_actions[] = '<li class="postedit"><span id="menu'.$cur_post['id'].'"><a onmouseover="ape_menu_hovered = true;" onmouseout="ape_menu_hovered = false;" onclick="if (ape_show_menu('.$cur_post['id'].')) {return true;} else {return false;}" href="edit_'.$cur_post['id'].'"><img src="engine/skins/images/comment_edit.png" align="absmiddle" alt=""/> '.$lang_topic['Edit'].'</a></span></li>';
		$post_actions[] = '<li class="postquote"><span><a href="post_tid'.$id.'"><img src="engine/skins/images/comment_add.png" align="absmiddle" alt=""/> '.$lang_topic['Quote'].'</a></span></li>';
		if ($quickpost)
			$post_actions[] = '<li class="postquote"><span id="pq'.$cur_post['id'].'"><a href="post_tid'.$id.'&amp;qid='.$cur_post['id'].'" onmousedown="get_quote_text()" onclick="Quote(\''.DBC_htmlspecialchars($cur_post['username']).'\','.$cur_post['id'].'); return false;"><img src="engine/skins/images/comment_add.png" align="absmiddle" alt=""/> '.$lang_topic['Quote_ajax'].'</a></span></li>';
//			$post_actions[] = '<li class="postquote"><span><a onmousedown="get_quote_text()" href="javascript:Quote(\''.DBC_htmlspecialchars($cur_post['username']).'\')">'.$lang_topic['QQuote'].'</a></span></li>';

	}

	// Perform the main parsing of the message (BBCode, smilies, censor words etc)

	$result_num_post = $db->query('SELECT count(message) as num_message FROM '.$db->prefix.'posts WHERE poster_id='.$DBC_user['id'].' AND topic_id='.$id, true) or error('Cannot found the amount of message of the user', __FILE__, __LINE__, $db->error());
	$num_post_user_in_topic = $db->fetch_assoc($result_num_post);
	$DBC_user['num_post_in_topic'] = $num_post_user_in_topic['num_message'];

	$cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
	$cur_post['warning'] = isset($warnings[$cur_post['id']]) ? $warnings[$cur_post['id']] : null;

	// Do signature parsing/caching
	if ($DBC_config['o_signatures'] == '1' && $cur_post['signature'] != '' && $DBC_user['show_sig'] != '0')
	{
		if (isset($signature_cache[$cur_post['poster_id']]))
			$signature = $signature_cache[$cur_post['poster_id']];
		else
		{
			$signature = parse_signature($cur_post['signature']);
			$signature_cache[$cur_post['poster_id']] = $signature;
		}
	}
?>


<script type="text/javascript">
function showCode<?php echo ($start_from + $post_count) ?>() {
$(function(){
	$('#code<?php echo ($start_from + $post_count) ?>').dialog({
		autoOpen: true,
		show: 'fade',
		hide: 'fade',
		 width: 550,
		height: 120,
                buttons: {
		"Закрыть" : function() {
                $(this).dialog("close");
            }
               }
	});
});
}
</script>
<div id="code<?php echo ($start_from + $post_count) ?>" title="<?php echo $lang_topic['Code for site'] ?>" style="display: none;">
<div style="width: auto; min-height: 111px; height: auto;overflow: auto;">
<div class="scriptcode"  onclick="this.select()"><?php echo $DBC_config['o_base_url'] ?>/topic_<?php echo $id ?>&p=<?php echo $p ?>#p<?php echo $cur_post['id'] ?></div><br/>
<?php echo $lang_topic['Code for site info'] ?>
</div>
</div>

<div id="p<?php echo $cur_post['id'] ?>" class="blockpost<?php echo ($post_count % 2 == 0) ? ' roweven' : ' rowodd' ?><?php if ($cur_post['id'] == $cur_topic['first_post_id']) echo ' firstpost'; ?><?php if ($post_count == 1) echo ' blockpost'; ?>">


<table border="0" cellpadding="0" cellspacing="0" width="100%"><thead><tr>
<td class="post_topic" align="center" width="217"><span <?php echo(($cur_post['gender'] != NULL) ? ' class="gender ' . $cur_post['gender'] . '"' : ''); ?>><span style="font-family: Tahoma;"><b><?php echo $username ?></b></span><a href="#req_message" onclick="return insert_text('', '[b]<?php echo DBC_htmlspecialchars($cur_post['username']) ?>[/b], ')">&nbsp;<img src="templates/Default/images/req_message.png" title="<?php echo $username_t ?>" border="0" alt="" /></a></span></td>
<td class="post_topic" style="padding: 0px 5px 0px 5px; font-size: 11px;color: #1d83b8;" align="left">



<table border="0" cellpadding="0" cellspacing="0" width="100%"><thead><tr>
<td align="left" width="50%">


<a class="conr_2 datepost" href="<?php echo $DBC_config['o_base_url'] ?>/topic_<?php echo $id ?>&p=<?php echo $p ?>#p<?php echo $cur_post['id'] ?>" ><?php echo format_time($cur_post['posted']) ?></a>


</td>
<td align="right" width="50%"><span class="conr window"><?php echo $lang_topic['Post'] ?> <a href='javascript:someFunction()' onclick="showCode<?php echo ($start_from + $post_count) ?>();">#<?php echo ($start_from + $post_count) ?></span></td>
</tr></thead></table>


</td>
</tr></thead></table>





	<div class="box">
		<div class="inbox">
			<div class="postbody">
				<div class="postleft">
					<ul class="user_details">


<div class="author_info">

<ul class="user_details"><li class="avatar"><span class="avatar_post"><?php if ($user_avatar != '') echo "\t\t\t\t\t\t".''.$user_avatar.''."\n"; ?></span><br/><span title="<?php echo $user_rank ?>"><?php echo generate_rank_image($cur_post['num_posts']) ?></span></li></ul>
<ul class="user_fields">
<li style="background: #f7f7f7;"><span class="ft_group"><?php echo $lang_topic['Group'] ?></span><span class="fc_group"><?php echo $user_title ?></strong></span></li>
<li><span class="ft_status"><?php echo $lang_topic['Status'] ?></span><span class="fc_status"><?php if ($cur_post['poster_id'] > 1) echo '<p>'.$is_online.'</p>'; ?></span></li>
<li style="background: #f7f7f7;"><?php require(DBC_ROOT.'engine/reputation/rep_viewtopic.php'); ?></li>
<?php if (count($user_postt)) echo "\t\t\t\t\t\t".implode("\n\t\t\t\t\t\t", $user_postt)."\n"; ?>
<li style="background: #f7f7f7;"><span class="ft_more"><a title="<?php echo $lang_topic['More'] ?>" href="javascript:ShowOrHide('Profile_detals<?php echo ($start_from + $post_count) ?>');"><?php echo $lang_topic['More'] ?></a></span><span class="fc_more"><a title="<?php echo $lang_topic['More'] ?>" href="javascript:ShowOrHide('Profile_detals<?php echo ($start_from + $post_count) ?>');"><img src="templates/Default/images/more_img.png" alt="" border="0" /></a></span></li>

</ul>

                              <div id="Profile_detals<?php echo ($start_from + $post_count) ?>" align="center" style="display: none;">
                              <ul class="reset_profile">
				<?php if (count($user_info)) echo "\t\t\t\t\t\t".implode("\n\t\t\t\t\t\t", $user_info)."\n"; ?>
                              </ul>
                              </div>


</div>
<center><div style="margin-bottom: 7px;"><?php if (count($user_contacts)) echo "\t\t\t\t\t\t".'<span class="contacts_profile" align="center">'.''.implode(' ', $user_contacts).'</span>'.''."\n"; ?></div></center>
</ul></div>






				<div class="postright">
					<h3><?php if ($cur_post['id'] != $cur_topic['first_post_id']) echo $lang_topic['Re'].' '; ?><?php echo DBC_htmlspecialchars($cur_topic['subject']) ?></h3>
					<div class="postmsg" id="post<?php echo $cur_post['id'] ?>">
						<?php echo $cur_post['message']."\n" ?>

<?php if ($cur_post['edited'] != '') echo "\t\t\t\t\t\t".'<p class="postedit"><em>'.$lang_topic['Last edit'].' '.DBC_htmlspecialchars($cur_post['edited_by']).' ('.format_time($cur_post['edited']).')</em></p>'."\n"; ?>
					</div>
<?php if (!is_null($cur_post['warning'])): ?>
					<div class="postwarn">
						<?php echo $cur_post['warning']."\n" ?>
					</div>
<?php endif; ?>
<?php if ($signature != '') echo "\t\t\t\t\t".'<div class="postsignature postmsg"><hr />'.$signature.'</div>'."\n"; ?>


				</div>
			</div>
		</div>


		<div class="inbox">
			<div class="postfoot clearb">
<?php if (count($post_actions)) echo "\t\t\t\t".'<div class="postfootright">'."\n\t\t\t\t\t".'<ul class="post_controls"><li id="info'.$cur_post['id'].'" style="display:none">'.$lang_ape['Loading'].'</li>'."\n\t\t\t\t\t\t".implode("\n\t\t\t\t\t\t", $post_actions)."\n\t\t\t\t\t".'</ul>'."\n\t\t\t\t".'</div>'."\n" ?>
			</div>
		</div>


	</div>
</div>


<?php

}

?>
<div id="aqp"></div>
<table width="100%" height="23" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" width="30" class="bg_forum_bott_left"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td align="left" class="bg_forum_bott_center"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td align="center" width="30" class="bg_forum_bott_right"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
</tr></thead></table>





<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="800%" align="left">


<script type="text/javascript" src="engine/classes/share_links/share_links.js"></script>
<script type="text/javascript">share_links('engine/classes/share_links/','<?php echo $link_topic ?>','<?php echo DBC_htmlspecialchars($cur_topic['subject']) ?>',150,20)</script>
<span class="subscription"><?php echo $subscraction ?></span></td><td width="20%" align="right">



<div class="search_topic">
<form method="get" action="search.php" style="padding: 2px;">
                <input type="hidden" name="action" value="search" />
                <input type="hidden" name="topic" value="<?php echo $id ?>" />
                <input type="text" class="input_text_search" value="Искать в теме..." onBlur="if(this.value=='') this.value='Искать в теме...';" onFocus="if(this.value=='Искать в теме...') this.value='';" name="keywords" maxlength="100" />
		<input type="submit" class="inputt_search" name="search" value="Поиск по теме" />
</form>
</div>
</td></tr></table>



<?php
if (defined('WITT_ENABLE'))
{
?>

<table border="0" cellpadding="0" cellspacing="0" height="23" width="100%"><thead><tr>
<td class="bg_forum_adv_left" align="left" width="30"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td class="bg_forum_adv_center" align="left"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td class="bg_forum_adv_right" align="center" width="30"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
</tr></thead></table>

<table class="forum_adv_table"  width="100%" border="0" cellpadding="0" cellspacing="0"><tr>
<td align="left" class="forum_adv_tleft" width="2"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td align="left" width="100%"><div class="forum_adv_c">

			<dl class="conl">
<?php

	$num_guests = count($witt_us[1]);
	$num_bots = 0;
	$num_users = count($witt_us) - 1;
	$users = array();
	$online_gid = DBC_htmlspecialchars($witt_us['g_id']);
	$witt_bt = $witt_us[1];
	unset($witt_us[1]);
	unset($witt_us[1]);

	foreach ($witt_us as $online_id => $online_name)
	{
		if ($DBC_user['g_view_users'] == '1')
			$users[] = "\n\t\t\t\t".'<a href="user_'.$online_id.'">'.DBC_htmlspecialchars($online_name).'</a>';
		else
			$users[] = "\n\t\t\t\t".''.DBC_htmlspecialchars($online_name);
	}
	foreach ($witt_bt as $online_name)
	{
		if (substr($online_name, 0, 5) == '[Bot]')
		{
		   ++$num_bots;
		   $users[] = "\n\t\t\t\t".'<dd>'.DBC_htmlspecialchars($online_name);
		}
	}

	echo "\t\t\t\t".'<dd><span>'.sprintf($lang_topic['Users online'], '<strong>'.forum_number_format($num_users).'</strong>').', '.sprintf($lang_topic['Guests online'], '<strong>'.forum_number_format($num_guests).'</strong>').'</span></dd>'."\n\t\t\t".'</dl>'."\n";;

 	if ($num_users + $num_bots > 0)
		echo "\t\t\t".'<span style="font-family: Verdana;"><hr />'.implode(',</dd> ', $users).''."\n\t\t\t".'</span>'."\n";
	else
		echo "\t\t\t".'<div class="clearer"></div>'."\n";

?>



</div></td>
<td align="left" class="forum_adv_tright" width="2"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
</td></tr></table>

<table width="100%" height="23" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" width="30" class="bg_forum_bott_left"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td align="left" class="bg_forum_bott_center"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td align="center" width="30" class="bg_forum_bott_right"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
</tr></thead></table>


<div class="linkst">
	<div class="inbox crumbsplus">
		<div class="pagepost">

			<p class="pagelink conl"><span class="contacts"><?php echo $paging_links ?></span></p>
			<span class="contacts" style="margin-left: 7px;"><a href="index.php"><?php echo $lang_common['Index'] ?></a>
			<span>»&#160;</span><a href="forum_<?php echo $cur_topic['forum_id'] ?>"><?php echo DBC_htmlspecialchars($cur_topic['forum_name']) ?></a>
			<span>»&#160;</span><?php echo DBC_htmlspecialchars($cur_topic['subject']) ?></span>
			 <?php echo $post_link ?>
		</div>
	</div>
</div>

<?php
}
// Display quick post if enabled
if ($quickpost)
{
	$cur_index = 1;

?>

<script type="text/javascript">
function showbb_info() {
$(function(){
	$('#bb_info').dialog({
		autoOpen: true,
		show: 'fade',
		hide: 'fade',
		 width: 230,
		height: 150,
                buttons: {
		"Закрыть" : function() {
                $(this).dialog("close");
            }
               }
	});
});
}
</script>
<div id="bb_info" title="BB Codes info" style="display: none;">
		<span style="text-align: left;">
		<span><a href="help.php#bbcode" onclick="window.open(this.href); return false;" class="bbhelp"><?php echo $lang_common['BBCode'] ?></a> <?php echo ($DBC_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></span>
		<p><span><a href="help.php#img" onclick="window.open(this.href); return false;" class="bbhelp"><?php echo $lang_common['img tag'] ?></a> <?php echo ($DBC_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></span></p>
		<p><span><a href="help.php#smilies" onclick="window.open(this.href); return false;" class="bbhelp"><?php echo $lang_common['Smilies'] ?></a> <?php echo ($DBC_config['o_smilies'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></span></p>
		</span>
		<ul class="bblinks" style="list-style: none;padding: 0px;"></ul>
</div>





<table width="100%" height="38" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" width="28" class="bg_forum_title_left"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td align="left" class="bg_forum_title_center"><span class="cat_title"><?php echo $lang_topic['Quick post'] ?></span></td>
<td align="center" width="28" class="bg_forum_title_right"><a href='javascript:someFunction()' onclick="showbb_info();" style="color: #ffffff;">[?]</a></td>



</tr></table>

<table class="forum_adv_table"  width="100%" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" class="forum_adv_tleft" width="2"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td align="left" width="100%"><div class="forum_adv">
<div id="quickpost">
	<div class="box">

		<form id="quickpostform" name="quickpostform" method="post" action="post_tid<?php echo $id ?>" onsubmit="this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}">
			<div class="inform">

						
						<input type="hidden" name="form_sent" value="1" />
						<input type="hidden" name="form_user" value="<?php echo DBC_htmlspecialchars($DBC_user['username']) ?>" />
<?php if ($DBC_config['o_subscriptions'] == '1' && ($DBC_user['auto_notify'] == '1' || $cur_topic['is_subscribed'])): ?>						<input type="hidden" name="subscribe" value="1" />
<?php endif; ?>
<div class="infldset">
<table width="100%" border="0">
<tr>
<td width="150" align="center" valign="top"><div class="post_avatar"><?php echo generate_avatar_markup($DBC_user['id']) ?></div>
<a href="user_<?php echo $DBC_user['id'] ?>"><span style="font-family: Verdana;"><?php echo DBC_htmlspecialchars($DBC_user['username']) ?></span></a><br/>

</td>
<td><div id="bbcode_bar"></div>
<script type="text/javascript">
	jQuery(function()
	{
		jQuery('textarea').autoResize();
	});
</script>
						<textarea class="input_text message" name="req_message" id="req_message" rows="7" cols="75" style="width: 99%;" tabindex="<?php echo $cur_index++ ?>" onclick="setNewField(this.name, document.getElementById( 'quickpostform' ))"></textarea>

</td></tr></table>
</div>
			<script type="text/javascript">
				var aqp_last_post_id = <?php echo $cur_topic['last_post_id'] ?>;
				var aqp_post_count = <?php echo $start_from + $post_count ?>;
				var aqp_tid = <?php echo $id ?>;
			</script>

			<p class="buttons">
				<input class="fbutton" type="submit" name="submit" onclick="if (aqp_post(this.form)) {return true;} else {return false;}" tabindex="<?php echo $cur_index++ ?>" value="<?php echo $lang_common['Submit'] ?>" accesskey="s" />
				<input class="fbutton" type="submit" name="preview" tabindex="<?php echo $cur_index++ ?>" value="<?php echo $lang_common['Preview'] ?>" accesskey="p" />
			</p>
			</div>
		</form>
	</div>
</div>


<br/>
</div></td>
<td align="left" class="forum_adv_tright" width="2"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
</td></tr></table>
<table width="100%" height="23" border="0" cellpadding="0" cellspacing="0"><thead><tr>
<td align="left" width="30" class="bg_forum_bott_left"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td align="left" class="bg_forum_bott_center"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
<td align="center" width="30" class="bg_forum_bott_right"><img src="engine/skins/images/spacer.gif" border="0" alt="" /></td>
</tr></thead></table>

<?php
require DBC_ROOT.'engine/bbcode.inc.php';

}

// Increment "num_views" for topic
if ($DBC_config['o_topic_views'] == '1' && !$DBC_user['is_bot'])
	$db->query('UPDATE '.$db->prefix.'topics SET num_views=num_views+1 WHERE id='.$id) or error('Unable to update topic', __FILE__, __LINE__, $db->error());

$forum_id = $cur_topic['forum_id'];
$footer_style = 'viewtopic';
require DBC_ROOT.'engine/footer.php';